package priv.abadstring.study.haoke.webapi.manage.graphql;

import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import priv.abadstring.study.haoke.dubbo.entity.HouseResources;
import priv.abadstring.study.haoke.webapi.manage.HouseResourcesManage;

/**
 * HouseResourcesDataFetcher
 *
 * @author aBadString
 * @date 2021-06-18 14:05:37
 */
@Component
public class HouseResourcesDataFetcher implements DataFetcherSpecification<HouseResources> {
    @Autowired
    private HouseResourcesManage houseResourcesManage;

    @Override
    public String fieldName() {
        return "HouseResources";
    }

    @Override
    public HouseResources dataFetcher(DataFetchingEnvironment args) {
        Long id = ((Integer) args.getArgument("id")).longValue();
        // 查询数据库
        return this.houseResourcesManage.getById(id);
    }
}
